package com.cloudcc.mobile.view.customer;

import android.content.Intent;

import com.cloudcc.cloudframe.adapter.CommonAdapter;
import com.cloudcc.cloudframe.bus.EventEngine;
import com.cloudcc.cloudframe.bus.IEventLife;
import com.cloudcc.cloudframe.util.ListUtils;
import com.cloudcc.mobile.adapter.CustomerListAdapter;
import com.cloudcc.mobile.entity.CustomerEntity;
import com.cloudcc.mobile.event.CustomerEventList.CustomerListEvent;
import com.cloudcc.mobile.view.activity.EditorActivity;

/**
 * 签到页面 --客户
 * 
 * @author Administrator
 * 
 */
public class CustomerListFragment extends BaseCustomerListFragment<CustomerEntity> implements IEventLife {

	@Override
	public void init() {
		register();
		super.init();
	}
	@Override
	public void onDestroy() {
		super.onDestroy();
		unRegister();
	}
	
	@Override
	protected CommonAdapter<CustomerEntity> createNewAdapter() {
		return new CustomerListAdapter(mContext);
	}

	
	
	public void onEventMainThread(CustomerListEvent event) {
		boolean shoudClear = mListView.refreshLoadMoreUI(
				ListUtils.isEmpty(event.getData()), event.isError(),
				isFromRefresh(), event.getMessage());
		handlerOnDataReqestFinish(shoudClear, event.getData());
	}
	
	@Override
	protected void onItemClick(int position, CustomerEntity t) {
		Intent intent=new Intent(mContext,EditorActivity.class);
		intent.putExtra("CustomerActivity","客户 "+"【" + t.getName() + "】");
		intent.putExtra("urlId", t.getId());
		intent.putExtra("reuevantType", "签到拜访");
		intent.putExtra("MapsActivity", location);
		intent.putExtra("key", "0");
		intent.putExtra("from", "map");
		intent.putExtra("name", "客户:"+t.getName());
		startActivity(intent);
		
	}
	
	
	
	@Override
	public void register() {
		EventEngine.register(this);
	}

	@Override
	public void unRegister() {
		EventEngine.uregister(this);
	}
	@Override
	protected String getObjApiName() {
		return "Account";
	}
}
